/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.AuthToken;
/*    */ import com.zimbra.cs.account.AuthTokenException;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Server;
/*    */ import com.zimbra.cs.account.ZimbraAuthToken;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.soap.JaxbUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.message.RefreshRegisteredAuthTokensRequest;
/*    */ import com.zimbra.soap.admin.message.RefreshRegisteredAuthTokensResponse;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class RefreshRegisteredAuthTokens
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 48 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 49 */     checkRight(zsc, context, null, AdminRight.PR_SYSTEM_ADMIN_ONLY);
/*    */     
/* 51 */     Provisioning prov = Provisioning.getInstance();
/* 52 */     Server localServer = prov.getLocalServer();
/* 53 */     if (localServer.getLowestSupportedAuthVersion() < 2) {
/* 54 */       return JaxbUtil.jaxbToElement(new RefreshRegisteredAuthTokensResponse());
/*    */     }
/*    */     
/* 57 */     RefreshRegisteredAuthTokensRequest req = (RefreshRegisteredAuthTokensRequest)JaxbUtil.elementToJaxb(request);
/* 58 */     List<String> tokens = req.getTokens();
/* 59 */     if ((tokens != null) && (!tokens.isEmpty())) {
/* 60 */       for (String token : tokens) {
/*    */         try {
/* 62 */           AuthToken zt = ZimbraAuthToken.getAuthToken(token);
/* 63 */           if (zt.isRegistered()) {
/* 64 */             Account acc = zt.getAccount();
/* 65 */             Provisioning.getInstance().reload(acc);
/* 66 */             ZimbraLog.soap.debug("Refreshed token %s for account %s", new Object[] { token, acc.getName() });
/*    */           }
/*    */         } catch (AuthTokenException|ServiceException e) {
/* 69 */           ZimbraLog.soap.error("Failed to refresh deregistered authtoken %s", token, e);
/*    */         }
/*    */       }
/*    */     }
/* 73 */     return JaxbUtil.jaxbToElement(new RefreshRegisteredAuthTokensResponse());
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 78 */     notes.add("Only system admins are allowed.");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/RefreshRegisteredAuthTokens.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */